// 部门列表
export const departments = [
  { label: '总经办', value: 'GMO' },
  { label: '人事行政部', value: 'HR' },
  { label: '财务部', value: 'Finance' },
  { label: '冲压车间', value: 'Press' },
  { label: '焊接车间', value: 'Assembly' },
  { label: '质量部', value: 'QA' },
  { label: '采购部', value: 'Purchasing' },
  { label: '工程部', value: 'Engineering' },
  { label: '运维部', value: 'Maintenance' },
  { label: '计划与物流部', value: 'Logistic' },
  { label: '商务部', value: 'SalesBusiness' },
];

// 每个部门的总人数映射
export const departmentTotalEmployees = {
  'GMO': 8,
  'HR': 7,
  'IT': 60,
  'Finance': 9,
  'Press': 49,
  'Assembly': 131,
  'QA': 39,
  'Purchasing': 6,
  'Engineering': 18,
  'Maintenance': 34,
  'Logistic': 46,
  'SalesBusiness': 5,
  '未指定': 50
}

// 获取图片的URL
export function getImageUrl(imagePath) {
  if (!imagePath) {
    return '';
  }
  const baseUrl = import.meta.env.VITE_APP_BASE_API;
  // 如果是完整的URL，直接返回
  if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
    return imagePath;
  }
  
  // 如果是控制器方法路径（/proposal/image/开头）
  if (imagePath.startsWith('/proposal/image/')) {
    return baseUrl + imagePath;
  }
  
  // 其他相对路径处理
  if (imagePath.startsWith('/')) {
    return baseUrl + imagePath;
  } else {
    return baseUrl + '/' + imagePath;
  }
}

// 计算奖金逻辑
export function calculateBonus(scoreForm) {
  // 如果选择了"不采纳"，奖金固定为5
  if (scoreForm.feasibilityResult === '不采纳') {
    return 5;
  }

  const { supervisorTotalScore, managerTotalScore, committeeTotalScore } = scoreForm;
  
  let finalScore = null;
  
  // 优先级：主管 -> 经理 -> 委员会
  if (committeeTotalScore !== null && committeeTotalScore > 0) {
    finalScore = committeeTotalScore;
  } else if (managerTotalScore !== null && managerTotalScore > 0) {
    finalScore = managerTotalScore;
  } else if (supervisorTotalScore !== null && supervisorTotalScore > 0) {
    finalScore = supervisorTotalScore;
  }
  
  // 如果三个评分都为null，则奖金为0
  if (finalScore === null) {
    return 0;
  } else {
    // 计算奖金
    let bonus = 0;
    
    if (finalScore >= 80) {
      bonus = 1200;
    } else if (finalScore >= 70) {
      bonus = 900;
    } else if (finalScore >= 60) {
      bonus = 600;
    } else if (finalScore >= 50) {
      bonus = 450;
    } else if (finalScore >= 40) {
      bonus = 300;
    } else if (finalScore >= 30) {
      bonus = 250;
    } else if (finalScore >= 20) {
      bonus = 150;
    } else if (finalScore >= 10) {
      bonus = 50;
    } else if (finalScore >= 5) {
      bonus = 20;
    } else if (finalScore >= 1) {
      bonus = 5;
    } else {
      bonus = 0;
    }
    
    return bonus;
  }
}

// 员工信息列表 
export const employees = [
  { id: '0400109', name: '周天意' },
  { id: '0400082', name: '罗辉煌' },
  { id: '0410035', name: '黄琳' },
  { id: '0400301', name: '钟红强' },
  { id: '0400136', name: '钟发明' },
  { id: '0400128', name: '杜新和' },
  { id: '0422163', name: '段晓宇' },
  { id: '0400150', name: '刘观生' },
  { id: '0400501', name: '朱邓军' },
  { id: '0400763', name: '宾勇亮' },
  { id: '0400808', name: '张勇' },
  { id: '0400798', name: '任宇' },
  { id: '0400506', name: '李翔' },
  { id: '0400085', name: '田宇新' },
  { id: '0400153', name: '钟卓' },
  { id: '0400792', name: '陈铁山' },
  { id: '0400047', name: '蒋启' },
  { id: '0400522', name: '刘志强' },
  { id: '0422063', name: '李振兴' },
  { id: '0400165', name: '张永流' },
  { id: '0400127', name: '王友' },
  { id: '0400148', name: '张谦' },
  { id: '0400027', name: '李乐恒' },
  { id: '0422230', name: '王少宇' },
  { id: '0400843', name: '胡开瑞' },
  { id: '0400831', name: '杨一帆' },
  { id: '0400834', name: '倪岸熙' },
  { id: '0400845', name: '李吉' },
  { id: '0400836', name: '贺新伟' },
  { id: '0400832', name: '陈训权' },
  { id: '0400842', name: '杨萱' },
  { id: '0400849', name: '彭培' }
];